package com.weixing.mall.provider.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.provider.mapper.SceneMapper;
import com.weixing.mall.provider.model.domain.Scene;
import com.weixing.mall.provider.model.dto.SceneDto;
import com.weixing.mall.provider.model.query.SceneQuery;
import com.weixing.mall.provider.service.ISceneService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author wx
 * @Date 2019/8/6 9:14
 * @Version 1.0
 */
/**
 * <p>
 * 商品模块-商品场景表 服务实现类
 * </p>
 *
 * @author Small
 * @since 2019-11-20
 */
@Service
public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements ISceneService {

    @Autowired
    private SceneMapper sceneMapper;
    @Override
    public IPage<Scene> findPage(Page page, SceneQuery sceneQuery) {
        return sceneMapper.selectList(page,sceneQuery);
    }
    @Override
    public void save(SceneDto sceneDto) {
        Scene scene = new Scene();
        BeanUtils.copyProperties(sceneDto,scene);
        if(null==sceneDto.getId()){
            save(scene);
        }else {
            updateById(scene);
        }
    }


    @Override
    public void deleteAll(int[] emp) {
        sceneMapper.delAll(emp);
    }
}
